#define AE_USEMEMORYMANAGER
#define AE_OPENGL
#include <AEEngine.h>

struct MyVertex
  {
    float x, y, z;        //Vertex
    float nx, ny, nz;     //Normal
    float s0, t0;         //Texcoord0
  };

MyVertex pvertex[3];
AEUINT16 pindices[3];

void prepareVertexAndIndexBuffer()
{
	//VERTEX 0
	pvertex[0].x = 0.0;
	pvertex[0].y = 0.0;
	pvertex[0].z = 0.0;
	pvertex[0].nx = 0.0;
	pvertex[0].ny = 0.0;
	pvertex[0].nz = 1.0;
	pvertex[0].s0 = 0.0;
	pvertex[0].t0 = 0.0;
	//VERTEX 1
	pvertex[1].x = 1.0;
	pvertex[1].y = 0.0;
	pvertex[1].z = 0.0;
	pvertex[1].nx = 0.0;
	pvertex[1].ny = 0.0;
	pvertex[1].nz = 1.0;
	pvertex[1].s0 = 1.0;
	pvertex[1].t0 = 0.0;
	//VERTEX 2
	pvertex[2].x = 0.0;
	pvertex[2].y = 1.0;
	pvertex[2].z = 0.0;
	pvertex[2].nx = 0.0;
	pvertex[2].ny = 0.0;
	pvertex[2].nz = 1.0;
	pvertex[2].s0 = 0.0;
	pvertex[2].t0 = 1.0;

	pindices[0] = 0;
	pindices[1] = 1;
	pindices[2] = 2;
}

void TestVertexBuffer()
{
	
	AEVertexBuffer *lpVertices = AEngine::GetVertexBufferManager()->CreateVertexBuffer( "test", 100, sizeof(MyVertex), AEMEMUSAGE_STATIC );

	//AEResourceManager resManager( AE_RESOURCEMANAGER_VERTEXBUFFER );
	//AEVertexBuffer gpuVertices( &resManager, 50, sizeof(MyVertex), AEMEMUSAGE_STATIC, AEFALSE );
	//AEGpuResource gpuIndices( &resManager, 50, AEMEMUSAGE_STATIC, AEBIND_INDEX_BUFFER, AEFALSE );

	prepareVertexAndIndexBuffer();
	
	lpVertices->FillWithData( &pvertex, 0, sizeof(MyVertex)*3 );

	AEVertexDescriptor vd;
	vd.m_sPosOfs = AEVERTEXDESC_FORMAT_FLOAT3;
	vd.m_sTexCoordOfs[0] = AEVERTEXDESC_FORMAT_FLOAT2;
	vd.m_sTexCoordOfs[1] = AEVERTEXDESC_FORMAT_FLOAT2;
	
	vd.m_sStride = sizeof(AEFLOAT32) * 7;

	//gpuIndices.FillWithData( &pindices, 0, sizeof(AEUINT16)*3 );
}